#ifndef HARD_WARE_H
#define HARD_WARE_H
#include <SD.h>
#include <esp32-hal-timer.h>
#include <Preferences.h>
#include <WiFi.h>
#include <lvgl.h>
// #include "lv_port_fatfs.h"

#include "hardware_drivers/imu.h"
#include "hardware_drivers/ambient.h"
#include "hardware_drivers/rgb_led.h"
#include "hardware_drivers/lv_port_fatfs.h"
#include <TJpg_Decoder.h>

#define LCD_BL_PIN 5
#define LCD_BL_PWM_CHANNEL 0

class Hardware
{
  private:
//   Display display;
    
    bool is_rgb_gradual_change=false;
    void init_rgb_gradual_change();
    void init_rgb_fliker();
    void init_red();
    void init_green();
    void event_ini();
    void event_run(Event);
    void init_display();
    void set_back_light(float);
    void init_sdcard();
    void auto_task();

    Pixel* rgb;
    Ambient* light_sen;
    int h=0;
    long timergbevent, timer_lux;
    TimerHandle_t xTimer_rgb=NULL;
    TimerHandle_t ev_green, ev_fliker, ev_red;
    TimerHandle_t ev_change;
    float aux, lux;
    IMU* imu;
    
    public:
      Hardware();
      void init_hardware();

      Action get_action(int);
      void main_process(Event);

      void rgb_gradual_change();
      void rgb_fliker();
      void color();
      void reset();
      void dis_lux();

      Preferences save_cfg;
      TimerHandle_t wifi_close_task, wifi_auto_task;
    
};

void rgb_gradual_change_callback(TimerHandle_t);
void rgb_fliker_callback(TimerHandle_t);
void color_callback(TimerHandle_t);
void Wifi_close_callback(TimerHandle_t);
void Wifi_auto_callback(TimerHandle_t);

#endif